package top.kaoshanji.p2ch18b;

/**
 * 代码清单-p2ch18b-207页d：封装角色
 * @author kaoshanji
 * ^_^
 * create time 2025/3/24 14:42
 */
public class Context {

    // 抽象策略
    private Strategy strategy = null;

    // 构造函数设置具体策略
    public Context(Strategy strategy) {
        this.strategy = strategy;
    }

    // 封装后的策略方法
    public void doAnything() {
        this.strategy.doSomething();
    }

}
